/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-02-20
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-03-02
 * @Description: 
 */
/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-02-20
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-03-02
 * @Description: 
 */
import 'package:chat_client/utils/emoji/emojis_map.dart';
import 'package:flutter/material.dart';

class EmojiPickerPanel extends StatelessWidget {
  final double height; // 面板高度
  final Color backgroundColor; // 背景颜色
  final int columns; // 每行表情数量
  final double iconSize; // 表情图标大小
  final EdgeInsetsGeometry padding; // 内边距
  final double spacing; // 表情间距
  final Function(String) onTap; // 点击回调

  const EmojiPickerPanel({
    super.key,
    this.height = 280,
    this.backgroundColor = Colors.white,
    this.columns = 7,
    this.iconSize = 34,
    this.padding = const EdgeInsets.all(10),
    this.spacing = 8,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      height: height,
      color: backgroundColor,
      child: GridView.builder(
          padding: padding,
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: columns,
            mainAxisSpacing: spacing,
            crossAxisSpacing: spacing,
          ),
          itemCount: Emoji.emojis.length,
          itemBuilder: (context, index) => _buildEmoji(Emoji.emojis[index])),
    );
  }

  _buildEmoji(emoji) {
    return GestureDetector(
      onTap: () => onTap(emoji),
      child: Text(
        emoji,
        style: TextStyle(fontSize: iconSize),
      ),
    );
  }
}
